/* 
    Purpose: The output of 2a_IncomeScores_1936 and 
             2b_IncomeScores_1936 are merged together 
             to create one file with 1936 income 
             scores at the occupation-only, race-only, 
             south-only, race x south, occupation x south, 
             occupation x race, and occupation x race x south
             levels. 
    
    Creates: ConsumptionSurvey_1936_IncomeScores.dta,
             ConsumptionSurvey_1936_IncomeScores_R.dta
*/

clear 
set more off

cd "$Mydirectory1/1_DataSources/ConsumptionSurvey_1936/"    

use ./output/ConsumptionSurvey_1936_IncomeScores_mainvariations.dta, clear

    merge 1:1 occ1950ej race south_merge using ./output/ConsumptionSurvey_1936_othervariations.dta, assert(3) nogen
    
    label var race "Race"
    label var south_merge "South"
    rename occ1950ej fatheroccej 
    label var fatheroccej "Father occupation"
    label var avg_totfaminc_1936_altwt "Avg. income using number of children as weights"

    keep fatheroccej race south_merge number_obs_cell_1936 avg_totfaminc_1936* flag_impute_1936 avg_totfaminc_1936_altwt
    
    compress    
    save ./output/ConsumptionSurvey_1936_IncomeScores.dta, replace 
    
   ***VERSION FOR ADULT CHILD SURVEY RESPONDENTS***
    preserve
        rename fatheroccej occRej
        rename south_merge south_merge_son
        
        save ./output/ConsumptionSurvey_1936_IncomeScores_R.dta, replace 

    restore 
